package com.sws.weixin.service.impl;

import com.sws.weixin.entity.UserMessage;
import com.sws.weixin.mapper.UserMessageMapper;
import com.sws.weixin.service.UserMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

// UserMessageServiceImpl.java
@Service
public class UserMessageServiceImpl implements UserMessageService {

    @Autowired
    private UserMessageMapper userMessageMapper;


    @Transactional
    public boolean saveMessage(UserMessage message) {
        // 设置默认发送时间
        if (message.getSendTime() == null) {
            message.setSendTime(new Date());
        }
        return userMessageMapper.insert(message) > 0;
    }
}